﻿<storeControls:StoreApplicationPage xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                                    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
                                    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
                                    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
                                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                                    xmlns:storeControls="clr-namespace:Store.WP7.Controls;assembly=Store.WP7.Controls"
                                    xmlns:behaviors="clr-namespace:Store.WP7.Framework.Interactions;assembly=Store.WP7.Framework"
                                    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                                    xmlns:ec="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
                                    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
                                    x:Class="Store.WP7.MainPage"
                                    mc:Ignorable="d"
                                    d:DesignWidth="480"
                                    d:DesignHeight="800"
                                    FontFamily="{StaticResource PhoneFontFamilyNormal}"
                                    FontSize="{StaticResource PhoneFontSizeNormal}"
                                    Foreground="{StaticResource PhoneForegroundBrush}"
                                    SupportedOrientations="Portrait"
                                    Orientation="Portrait"
                                    DataContext="{Binding MainPageViewModel, Source={StaticResource ViewModelLocator}}">

    <i:Interaction.Behaviors>
        <behaviors:SystrayBehavior SystrayOpacity="0.5"
                                   IsBusy="{Binding IsBusy}"
                                   BusyMessage="{Binding BusyMessage}" />
    </i:Interaction.Behaviors>

    <Grid x:Name="LayoutRoot"
          Background="Transparent">

        <controls:Panorama Style="{StaticResource PanoramaStyle}"
                           x:Name="mainPanorama">
            <i:Interaction.Behaviors>
                <behaviors:TrackablePanoramaBehavior SelectedIndex="{Binding PanoramaIndex, Mode=TwoWay}" />
            </i:Interaction.Behaviors>

            <controls:Panorama.Background>
                <ImageBrush Stretch="Fill"
                            ImageSource="/Assets/Images/PanoramaBackground.png" />
            </controls:Panorama.Background>

            <controls:PanoramaItem Header="produits"
                                   Style="{StaticResource PanoramaItemStyle}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>


                    <ListBox ItemsSource="{Binding Products}"
                             ItemTemplate="{StaticResource ProductSummaryDataTemplate}"
                             SelectedItem="{Binding SelectedProduct, Mode=TwoWay}"
                             x:Name="ProductsListBox">

                        <i:Interaction.Behaviors>
                            <behaviors:ContinuumMasterBehavior />
                        </i:Interaction.Behaviors>

                    </ListBox>


                    <Button Content="plus de produits..."
                            Grid.Row="1"
                            Margin="0,6,0,6"
                            Style="{StaticResource ButtonStyle}">
                        <i:Interaction.Behaviors>
                            <behaviors:BoolValueVisibilityBehavior Value="{Binding AreProductsLoaded}" />
                        </i:Interaction.Behaviors>
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <ec:CallMethodAction MethodName="OnGoToMoreProductsView"
                                                     TargetObject="{Binding Mode=OneWay}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                </Grid>
            </controls:PanoramaItem>

            <controls:PanoramaItem Header="commandes"
                                   Style="{StaticResource PanoramaItemStyle}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <ListBox ItemsSource="{Binding Orders}"
                             Width="420"
                             SelectedItem="{Binding SelectedOrder, Mode=TwoWay}"
                             toolkit:TiltEffect.IsTiltEnabled="True">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid Height="78"
                                      Width="432"
                                      Margin="0,0,0,10">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="12" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <Grid Height="45"
                                          Width="45"
                                          VerticalAlignment="Center">
                                        <Rectangle Fill="{StaticResource AccentBrushDark}" />
                                        <Border Background="{StaticResource AccentBrushLight}"
                                                Margin="6,6,-6,-6" />
                                        <Image HorizontalAlignment="Center"
                                               VerticalAlignment="Center"
                                               Source="/icons/caddy.white.png"
                                               Width="30"
                                               Height="30"
                                               Margin="6,6,0,0" />
                                    </Grid>
                                    <StackPanel Grid.Column="2">
                                        <TextBlock Text="{Binding OrderDate, StringFormat=\{0:D\}}"
                                                   TextWrapping="Wrap"
                                                   Style="{StaticResource PhoneTextExtraLargeStyle}"
                                                   Foreground="{StaticResource ForegroundBrush}" />
                                        <TextBlock Text="{Binding State}"
                                                   TextWrapping="Wrap"
                                                   Margin="12,-6,12,0"
                                                   Style="{StaticResource PhoneTextSubtleStyle}"
                                                   Foreground="{StaticResource AccentBrushDark}" />
                                    </StackPanel>
                                </Grid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>

                    <Button Content="plus de commandes..."
                            Grid.Row="1"
                            Margin="0,6,0,6"
                            Style="{StaticResource ButtonStyle}">
                        <i:Interaction.Behaviors>
                            <behaviors:BoolValueVisibilityBehavior Value="{Binding AreOrdersLoaded}" />
                        </i:Interaction.Behaviors>
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <ec:CallMethodAction MethodName="OnGoToMoreOrdersView"
                                                     TargetObject="{Binding Mode=OneWay}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                </Grid>
            </controls:PanoramaItem>

            <controls:PanoramaItem Header="panier"
                                   Style="{StaticResource PanoramaItemStyle}">

                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <ItemsControl ItemsSource="{Binding BasketProducts}"
                                  HorizontalAlignment="Left"
                                  Width="420"
                                  Margin="-4,0,-4,0">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <toolkit:WrapPanel Orientation="Horizontal" />
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                        <ItemsControl.Template>
                            <ControlTemplate>
                                <ScrollViewer Padding="{TemplateBinding Padding}">
                                    <ItemsPresenter />
                                </ScrollViewer>
                            </ControlTemplate>
                        </ItemsControl.Template>
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Margin="0,0,0,16">
                                    <Grid Height="190"
                                          Width="190"
                                          Margin="4">
                                        <Image Source="{Binding PictureUrl}" />
                                        <Grid VerticalAlignment="Top"
                                              HorizontalAlignment="Right"
                                              Margin="0,-2,-2,0">
                                            <Rectangle Fill="{StaticResource AccentBrushLight}" />
                                            <TextBlock HorizontalAlignment="Right"
                                                       TextWrapping="Wrap"
                                                       Text="{Binding Price}"
                                                       Foreground="White"
                                                       Margin="3,2"
                                                       FontFamily="Segoe WP Black" />
                                        </Grid>
                                        <Grid VerticalAlignment="Bottom"
                                              HorizontalAlignment="Left"
                                              Margin="0,-2,-2,0">
                                            <Rectangle Fill="{StaticResource AccentBrushDark}" />
                                            <TextBlock HorizontalAlignment="Right"
                                                       TextWrapping="Wrap"
                                                       Foreground="White"
                                                       Margin="4,2"
                                                       FontFamily="Segoe WP Black"
                                                       Text="x1" />
                                        </Grid>
                                    </Grid>
                                    <TextBlock Text="{Binding Title}"
                                               TextWrapping="Wrap"
                                               Width="173"
                                               FontSize="21.333"
                                               FontFamily="Segoe WP Black"
                                               Foreground="{StaticResource ForegroundBrush}"
                                               Height="60"
                                               TextTrimming="WordEllipsis" />
                                </StackPanel>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>

                    <TextBlock Text="Vide est votre panier :("
                               FontFamily="Segoe WP Black"
                               FontSize="{StaticResource PhoneFontSizeLarge}"
                               Margin="0,100,0,0"
                               HorizontalAlignment="Center">
                    <i:Interaction.Behaviors>
                    <behaviors:BoolValueVisibilityBehavior Value="{Binding IsBasketEmpty}" />
                  </i:Interaction.Behaviors>
                    </TextBlock>

                    <Button Content="Commander"
                            Grid.Row="1"
                            Margin="0,6,0,6"
                            Style="{StaticResource ButtonImportantStyle}">
                        <i:Interaction.Behaviors>
                            <behaviors:BoolValueVisibilityBehavior Value="{Binding IsBasketEmpty}"
                                                                   Negate="True" />
                        </i:Interaction.Behaviors>
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <ec:CallMethodAction MethodName="OnGoToCheckOutView"
                                                     TargetObject="{Binding Mode=OneWay}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                </Grid>
            </controls:PanoramaItem>

            <controls:PanoramaItem Header="options"
                                   Style="{StaticResource PanoramaItemStyle}">
                <StackPanel>
                    <Button Style="{StaticResource ButtonPressedEffectNoStyle}"
                            Margin="0,0,0,24">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <behaviors:ExecuteCommandAction Command="{Binding GoToSettingsCommand}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="12" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <Grid Grid.Row="0"
                                  Height="45"
                                  Width="45"
                                  VerticalAlignment="Center">
                                <Rectangle Fill="{StaticResource AccentBrushDark}" />
                                <Rectangle Fill="{StaticResource AccentBrushLight}"
                                           Margin="6,6,-6,-6" />
                                <Image Source="/icons/appbar.feature.settings.rest.png"
                                       Margin="6,6,-6,-6" />
                            </Grid>
                            <TextBlock Grid.Column="2"
                                       Text="paramètres"
                                       Style="{StaticResource PhoneTextExtraLargeStyle}"
                                       Foreground="{StaticResource ForegroundBrush}" />
                        </Grid>
                    </Button>

                    <Button Style="{StaticResource ButtonPressedEffectNoStyle}"
                            Margin="0,0,0,24">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <behaviors:ExecuteCommandAction Command="{Binding GoToInfosCommand}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="12" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <Grid Grid.Row="0"
                                  Height="45"
                                  Width="45"
                                  VerticalAlignment="Center">
                                <Rectangle Fill="{StaticResource AccentBrushDark}" />
                                <Rectangle Fill="{StaticResource AccentBrushLight}"
                                           Margin="6,6,-6,-6" />
                                <Image Source="/icons/info.png"
                                       Margin="6,6,-6,-6" />
                            </Grid>
                            <TextBlock Grid.Column="2"
                                       Text="informations"
                                       Style="{StaticResource PhoneTextExtraLargeStyle}"
                                       Foreground="{StaticResource ForegroundBrush}" />
                        </Grid>
                    </Button>

                    <Button Style="{StaticResource ButtonPressedEffectNoStyle}"
                            Margin="0,0,0,24">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <behaviors:ExecuteCommandAction Command="{Binding RateAppCommand}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="12" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <Grid Grid.Row="0"
                                  Height="45"
                                  Width="45"
                                  VerticalAlignment="Center">
                                <Rectangle Fill="{StaticResource AccentBrushDark}" />
                                <Rectangle Fill="{StaticResource AccentBrushLight}"
                                           Margin="6,6,-6,-6" />
                                <Image Source="/icons/appbar.edit.rest.png"
                                       Margin="6,6,-6,-6" />
                            </Grid>
                            <TextBlock Grid.Column="2"
                                       Text="noter l'application"
                                       Style="{StaticResource PhoneTextExtraLargeStyle}"
                                       Foreground="{StaticResource ForegroundBrush}" />
                        </Grid>
                    </Button>

                    <Button Style="{StaticResource ButtonPressedEffectNoStyle}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <behaviors:ExecuteCommandAction Command="{Binding SendMailCommand}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="12" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <Grid Grid.Row="0"
                                  Height="45"
                                  Width="45"
                                  VerticalAlignment="Center">
                                <Rectangle Fill="{StaticResource AccentBrushDark}" />
                                <Rectangle Fill="{StaticResource AccentBrushLight}"
                                           Margin="6,6,-6,-6" />
                                <Image Source="/icons/appbar.feature.email.rest.png"
                                       Margin="6,6,-6,-6" />
                            </Grid>
                            <TextBlock Grid.Column="2"
                                       Text="contactez-nous"
                                       Style="{StaticResource PhoneTextExtraLargeStyle}"
                                       Foreground="{StaticResource ForegroundBrush}" />
                        </Grid>
                    </Button>
                </StackPanel>
            </controls:PanoramaItem>

        </controls:Panorama>
    </Grid>

</storeControls:StoreApplicationPage>
